<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>
    const arr = [{ top: 5 }, { top: 9 }, { top: 1 }, { top: 7 }, { top: -5 }, { top: -3 }]

    //  求非负数的最小值 

    console.time();
    var a = arr.filter(v => v.top >= 0).sort((a, b) => {
        if (a.top > b.top) {
            return 1
        } else {
            return -1
        }
    })
    console.timeEnd();
    console.log(a[0]);
</script>

</html>